package com.cn.dream_order_server.controller;

import com.cn.dream_order_server.service.OrderCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.LinkedHashMap;

@RestController
public class PublicOrderCarController {

    @Autowired
    private OrderCartService orderCartService;

    @RequestMapping("/wlcSaveOrderShopping")
    public Object wlcSaveOrderShopping(@RequestBody LinkedHashMap<String,Object> map, HttpSession session){
        System.out.println("111111");
        //从session中获取用户信息
        String commodity_id=(String)map.get("commodity_id");
        Integer shopping_num=(Integer)map.get("shopping_num");
        Integer l=(Integer)map.get("price");
        long price = l.longValue();
        Object userStaff = session.getAttribute("userStaff");
        Integer integer = orderCartService.saveOrderShoppingByCommodity_id(commodity_id, shopping_num, price, "1");
        Boolean flag = false;
        if (integer!=null){
            flag=true;
        }
        return flag;
    }

}
